/**
 * @author		Sergey Suzdalskiy
 * @e-mail:		sergey.suzdalskiy@gmail.com
 */
package ua.kiev.gcore.money
{
	public class Price
	{
		public var moneyCount:Number;
		public var moneyType:String;
		public var itemCount:int;
		
		public function Price(moneyType:String, moneyCount:Number, itemCount:int = 1)
		{
			this.moneyCount = moneyCount;
			this.moneyType = moneyType;
			this.itemCount = itemCount;
		}
		
		public function toString(fixed:int = 999, suffix:String = "k"):String{
			var result:String = new String();
			var countSuffix:String = new String();
			var count:Number = moneyCount;
			
			
			if(itemCount > 0){
				count = count * itemCount;
			}
			
			while(count > fixed){
				count = count/(fixed+1);
				countSuffix += suffix;
			}
			result = count.toString() + countSuffix;
			return result;
		}
	}
}